var http=require('../../../utils/https')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    orderDetail: [
      {
        id: null,
        totalAmount: 0,
        remark: "",
        quantity: 0,
        subtotal: 0,
        productName: '',
        mainImages: '',
      }
    ],
    address:{
      name:'',
      phone:'',
      address:'',
    },
    time:{
      createAt:'',
      updateAt:''
    },
    totalAmount:0.0,
    id:0,
  },


  toVIPCode() {
    wx.navigateTo({
      url: '/index/pages/mzhVIPCode/mzhVIPCode',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options.id);
    var id = options.id
    
    
    // 获取订单时间
    http.GET(`/order/orders/selfTime/${id}`, {}, (res) => {
      console.log('成功:', res);
      if(res.code===200){
       this.setData({
         time:res.data
       })
      }
    }, (err) => {
      console.error('失败:', err);
    });
    
    // 获取订单详情
    http.GET(`/order/orders/selfOrderDetail/${id}`, {}, (res) => {
      console.log('成功:', res);
      if(res.code===200){
        this.setData({
          orderDetail:res.data,
          totalAmount:res.data[0].totalAmount,
          id:res.data[0].id
        })
      }
    }, (err) => {
      console.error('失败:', err);
    });

    // 获取订单地址
    http.GET(`/order/orders/selfAddress/${id}`, {}, (res) => {
      console.log('成功:', res);
      this.setData({
        address:res.data
      })
    }, (err) => {
      console.error('失败:', err);
    });
  },
  
  


})